#!/bin/sh
# 快速部署应用，打开远程调试端口
# 有利于开发效率
# ivanzhang @ 2011.8.28
#########################
DEBUG_PORT=0
if [ $1 != "" ]; then
   DEBUG_PORT="$1"
else
   DEBUG_PORT="8090"
fi

WAR_FILE=`find deploy/war/target/ -name "*.war.war"`
BASE_DIR=`dirname $0`
JETTY_SERVER_HOME="$BASE_DIR/jetty7.0.2"
JAVA="$JAVA_HOME/bin/java"
JAVA_OPTIONS="-server  -DName=bbplatform -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=$DEBUG_PORT,server=y,suspend=n"

if [ ! -d $JETTY_SERVER_HOME ]; then 
	echo "Can't find Jetty Server!";
	exit 1;
fi

#将war包拷贝到jetty下面，然后启动jetty服务器.
if [ $WAR_FILE=="" ]; then 
 echo "ERROR, No Found The War.";
 exit 1;
fi

echo "================="
echo "Begin Deploy ,War file is :$WAR_FILE"
echo "================="
cp $WAR_FILE "$JETTY_SERVER_HOME/webapps/bbplatform.war"

#启动Jetty ，并以debug_port运行
cd "$JETTY_SERVER_HOME"
$JAVA $JAVA_OPTIONS -jar start.jar &




